<?php


namespace Frieza\Modules\RiskContent\Actions;

use Encore\Admin\Grid\Tools\BatchAction;

class BatchForbidden  extends BatchAction
{
    protected $action;

    public function __construct($action = 1)
    {
        $this->action = $action;
    }
    public function script()
    {
        return <<<EOT
        
$('{$this->getElementClass()}').on('click', function() {

    $.ajax({
        method: 'post',
        url: '/admin/RiskContent/batchForbidden/batchForbiddenInfo',
        data: {
            _token:'{$this->getToken()}',
            ids: $.admin.grid.selected(),
            action: {$this->action}
        },
        success: function (e) {
            if (e.code == 1) {
                swal({
                    title: e.title,
                    type: "warning",
                });
                setTimeout(function () {
                    $.pjax.reload('#pjax-container');
                }, 1000);
            } else {
                toastr.error(e.title, null, {
                    timeOut : 3000
                }); 
            }
        }
    });
});

EOT;

    }
}